package NLP;

import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.dictionary.py.Pinyin;
import entity.Word;

import java.util.ArrayList;
import java.util.List;


public class PinYin {
    /**
     * 设置word.Tone, word.yunmu
     * @see entity.Word
     * @param word 需要注音的 Word
     * @return
     */
    public static void pinyinNotation(Word word){
        List<Pinyin> pinYinList = HanLP.convertToPinyinList(word.getWord());
        List<String> tones = new ArrayList<String>();
        List<String> yunmus = new ArrayList<String>();
        for (Pinyin pinYin:pinYinList){
            tones.add(pinYin.getTone()+"");
            yunmus.add(pinYin.getYunmu().toString());
        }
        word.setTone(tones);
        word.setYunmu(yunmus);
    }

}
